home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / windows / ocx / ipack.exe / RASDIAL.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-08-18  |  10.7 KB  |  336 lines

  1. VERSION 4.00
  2. Begin VB.Form RASDial 
  3.    Caption         =   "RASDial"
  4.    ClientHeight    =   5385
  5.    ClientLeft      =   1620
  6.    ClientTop       =   2205
  7.    ClientWidth     =   8175
  8.    Height          =   5790
  9.    Left            =   1560
  10.    LinkTopic       =   "RASDial"
  11.    LockControls    =   -1  'True
  12.    ScaleHeight     =   5385
  13.    ScaleWidth      =   8175
  14.    Top             =   1860
  15.    Width           =   8295
  16.    Begin VB.Frame Frame3 
  17.       Caption         =   "Phone Book"
  18.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  19.          Name            =   "MS Sans Serif"
  20.          Size            =   8.25
  21.          Charset         =   0
  22.          Weight          =   700
  23.          Underline       =   0   'False
  24.          Italic          =   0   'False
  25.          Strikethrough   =   0   'False
  26.       EndProperty
  27.       Height          =   1095
  28.       Left            =   240
  29.       TabIndex        =   10
  30.       Top             =   2160
  31.       Width           =   5055
  32.       Begin VB.TextBox txtPhoneBook 
  33.          Height          =   285
  34.          Left            =   240
  35.          TabIndex        =   13
  36.          Top             =   360
  37.          Width           =   2895
  38.       End
  39.       Begin VB.CommandButton cmdRefresh 
  40.          Caption         =   "Refresh"
  41.          Height          =   495
  42.          Left            =   3240
  43.          TabIndex        =   12
  44.          Top             =   360
  45.          Width           =   1575
  46.       End
  47.    End
  48.    Begin VB.Frame Frame2 
  49.       Caption         =   "Connect State"
  50.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  51.          Name            =   "MS Sans Serif"
  52.          Size            =   8.25
  53.          Charset         =   0
  54.          Weight          =   700
  55.          Underline       =   0   'False
  56.          Italic          =   0   'False
  57.          Strikethrough   =   0   'False
  58.       EndProperty
  59.       Height          =   1815
  60.       Left            =   240
  61.       TabIndex        =   4
  62.       Top             =   3360
  63.       Width           =   5055
  64.       Begin VB.ListBox lstConnectState 
  65.          Height          =   1230
  66.          ItemData        =   "RASDial.frx":0000
  67.          Left            =   240
  68.          List            =   "RASDial.frx":0002
  69.          TabIndex        =   5
  70.          Top             =   360
  71.          Width           =   4575
  72.       End
  73.    End
  74.    Begin VB.Frame Frame1 
  75.       Caption         =   "Phone Book Entries"
  76.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  77.          Name            =   "MS Sans Serif"
  78.          Size            =   8.25
  79.          Charset         =   0
  80.          Weight          =   700
  81.          Underline       =   0   'False
  82.          Italic          =   0   'False
  83.          Strikethrough   =   0   'False
  84.       EndProperty
  85.       Height          =   1935
  86.       Left            =   240
  87.       TabIndex        =   0
  88.       Top             =   120
  89.       Width           =   5055
  90.       Begin VB.ListBox lstEntries 
  91.          Height          =   1425
  92.          ItemData        =   "RASDial.frx":0004
  93.          Left            =   240
  94.          List            =   "RASDial.frx":0006
  95.          TabIndex        =   3
  96.          Top             =   360
  97.          Width           =   2895
  98.       End
  99.       Begin VB.CommandButton cmdConnect 
  100.          Caption         =   "Connect"
  101.          Enabled         =   0   'False
  102.          Height          =   495
  103.          Left            =   3240
  104.          TabIndex        =   2
  105.          Top             =   360
  106.          Width           =   1575
  107.       End
  108.       Begin VB.CommandButton cmdDisconnect 
  109.          Caption         =   "Disconnect"
  110.          Enabled         =   0   'False
  111.          Height          =   495
  112.          Left            =   3240
  113.          TabIndex        =   1
  114.          Top             =   960
  115.          Width           =   1575
  116.       End
  117.    End
  118.    Begin RasLib.mRAS mRAS1 
  119.       Left            =   7560
  120.       Top             =   4800
  121.       _Version        =   65536
  122.       _ExtentX        =   847
  123.       _ExtentY        =   847
  124.       _StockProps     =   64
  125.       PhoneBook       =   ""
  126.       PhoneNumber     =   ""
  127.       LogonName       =   ""
  128.       LogonPassword   =   ""
  129.       CallbackNumber  =   ""
  130.       EntryName       =   ""
  131.       Domain          =   ""
  132.       Blocking        =   0   'False
  133.    End
  134.    Begin VB.Label lblRefresh 
  135.       Caption         =   $"RASDial.frx":0008
  136.       Height          =   975
  137.       Left            =   5400
  138.       TabIndex        =   11
  139.       Top             =   2280
  140.       Width           =   2535
  141.    End
  142.    Begin VB.Label lblConnecting 
  143.       Caption         =   $"RASDial.frx":009E
  144.       Height          =   1455
  145.       Left            =   5400
  146.       TabIndex        =   9
  147.       Top             =   3480
  148.       Visible         =   0   'False
  149.       Width           =   2535
  150.    End
  151.    Begin VB.Label lblDisconnect 
  152.       Caption         =   "You are now connected to the server.  When you are done, press the Disconnect button and RAS will hang-up the phone (Disconnect)."
  153.       Height          =   855
  154.       Left            =   5400
  155.       TabIndex        =   8
  156.       Top             =   960
  157.       Visible         =   0   'False
  158.       Width           =   2535
  159.    End
  160.    Begin VB.Label lblConnect 
  161.       Caption         =   $"RASDial.frx":0170
  162.       Height          =   1455
  163.       Left            =   5400
  164.       TabIndex        =   7
  165.       Top             =   600
  166.       Visible         =   0   'False
  167.       Width           =   2535
  168.    End
  169.    Begin VB.Label lblSelect 
  170.       Caption         =   "Listed to the left are all the entries in the current phone book.  Select one of the phone book entries."
  171.       Height          =   615
  172.       Left            =   5400
  173.       TabIndex        =   6
  174.       Top             =   240
  175.       Visible         =   0   'False
  176.       Width           =   2535
  177.    End
  178. Attribute VB_Name = "RASDial"
  179. Attribute VB_Creatable = False
  180. Attribute VB_Exposed = False
  181. Option Explicit
  182. Private Sub DisableControl(C As Control)
  183.    ' Prevent flashing by changing the
  184.    ' state only if needed
  185.    If C.Enabled <> False Then
  186.       C.Enabled = False
  187.    End If
  188. End Sub
  189. Private Sub EnableControl(C As Control)
  190.    ' Prevent flashing by changing the
  191.    ' state only if needed
  192.    If C.Enabled = False Then
  193.       C.Enabled = True
  194.    End If
  195. End Sub
  196. Private Sub HideControl(C As Control)
  197.    ' Prevent flashing by changing the
  198.    ' state only if needed
  199.    If C.Visible <> False Then
  200.       C.Visible = False
  201.    End If
  202. End Sub
  203. Sub LoadEntries()
  204.    Dim I
  205.    lstEntries.Clear
  206.    ' Load the phone book entries list with
  207.    ' the current list of entries from the
  208.    ' RAS control
  209.    For I = 0 To mRAS1.EntryCount - 1
  210.       lstEntries.AddItem mRAS1.EntryList(I)
  211.    Next I
  212.       
  213.    ShowControl lblSelect
  214. End Sub
  215. Private Sub ShowControl(C As Control)
  216.    ' Prevent flashing by changing the
  217.    ' state only if needed
  218.    If C.Visible = False Then
  219.       C.Visible = True
  220.    End If
  221. End Sub
  222. Private Sub cmdConnect_Click()
  223.    On Error Resume Next
  224.    ' Use the entry selected by the user
  225.    mRAS1.EntryName = lstEntries.Text
  226.    mRAS1.GetEntry
  227.    'When using NT, the phonebook property
  228.    'must be set. If an error occurs opening
  229.    'the phonebook, prompt for the phonebook file.
  230.    If Err > 20620 And Err < 20626 Then
  231.         Dim TempStr As String
  232.         TempStr = "If using NT, the Phonebook property must be set." & vbCr & vbCrLf
  233.         TempStr = TempStr & "The default system phonebook for NT 4.0 is" & vbCrLf
  234.         TempStr = TempStr & Chr$(34) & "C:\WINNT\SYSTEM32\RAS\RASPHONE.PBK" & Chr$(34) & vbCr & vbCrLf
  235.         TempStr = TempStr & "The default system phonebook for NT 3.51 is" & vbCrLf
  236.         TempStr = TempStr & Chr$(34) & "C:\WINNT35\SYSTEM32\RAS\RASPHONE.PBK" & Chr$(34) & vbCr & vbCrLf
  237.         TempStr = TempStr & "Enter the path and name of the phonebook, or press Cancel to abort." & vbCrLf
  238.         mRAS1.PhoneBook = InputBox(TempStr, "Enter Phonebook", "C:\WINNT\SYSTEM32\RAS\RASPHONE.PBK")
  239.         If mRAS1.PhoneBook = "" Then
  240.             Exit Sub
  241.         ElseIf Dir$(mRAS1.PhoneBook) = "" Then
  242.             MsgBox "Unable to locate phonebook file: " & vbCrLf & mRAS1.PhoneBook
  243.             Exit Sub
  244.         End If
  245.         On Error GoTo 0
  246.         mRAS1.GetEntry
  247.    End If
  248.    ' Connect to server
  249.    lstConnectState.Clear
  250.    DisableControl cmdConnect
  251.    DisableControl cmdRefresh
  252.    DisableControl txtPhoneBook
  253.    DisableControl lstEntries
  254.    HideControl lblRefresh
  255.    HideControl lblConnect
  256.    ShowControl lblConnecting
  257.    DoEvents
  258.    mRAS1.Connect
  259. End Sub
  260. Private Sub cmdDisconnect_Click()
  261.    ' Disconnect from server.
  262.    mRAS1.Disconnect
  263.    ' Enable appropriate controls
  264.    EnableControl lstEntries
  265.    DisableControl cmdDisconnect
  266.    EnableControl cmdConnect
  267.    HideControl lblDisconnect
  268.    ShowControl lblConnect
  269. End Sub
  270. Private Sub cmdRefresh_Click()
  271.    mRAS1.PhoneBook = txtPhoneBook
  272.    mRAS1.Refresh
  273.    LoadEntries
  274.    lstEntries_Click
  275.    HideControl lblConnect
  276.    ShowControl lblSelect
  277. End Sub
  278. Private Sub Form_Load()
  279.    ' Check for RAS services ...
  280.    If (mRAS1.RASAvailable = False) Then
  281.       MsgBox "RAS Services are not available.  This program will not function without them.", vbOKOnly Or vbCritical, "Mabry RAS Dialer Sample"
  282.       End
  283.       End If
  284.       
  285.    ' Move to the upper left corner of the screen
  286.    Me.Move 720, 720
  287.    ' Load phone book entries from table
  288.    LoadEntries
  289. End Sub
  290. Private Sub lstEntries_Click()
  291.    If lstEntries.ListIndex = -1 Then
  292.       DisableControl cmdConnect
  293.       HideControl lblConnect
  294.       ShowControl lblSelect
  295.    Else
  296.       EnableControl cmdConnect
  297.       ShowControl lblConnect
  298.       HideControl lblSelect
  299.    End If
  300. End Sub
  301. Private Sub lstEntries_DblClick()
  302.    ' Connect to the selected server.
  303.    cmdConnect_Click
  304. End Sub
  305. Private Sub mRAS1_AsyncError(ErrorCode As Integer)
  306.    If mRAS1.ConnectState = 8193 Then
  307.       ' Not connected
  308.       EnableControl cmdRefresh
  309.       EnableControl txtPhoneBook
  310.       ShowControl lblRefresh
  311.       
  312.       EnableControl cmdConnect
  313.       EnableControl lstEntries
  314.       
  315.       HideControl lblConnecting
  316.       ShowControl lblConnect
  317.    End If
  318. End Sub
  319. Private Sub mRAS1_Done()
  320.    ' Done with connection?
  321.    If mRAS1.ConnectState = 8192 Then
  322.       ' Connected
  323.       EnableControl cmdRefresh
  324.       EnableControl txtPhoneBook
  325.       EnableControl cmdDisconnect
  326.       
  327.       ShowControl lblRefresh
  328.       HideControl lblConnecting
  329.       ShowControl lblDisconnect
  330.    End If
  331. End Sub
  332. Private Sub mRAS1_Progress(ByVal ConnectState As Integer)
  333.    lstConnectState.AddItem ConnectState & " " & mRAS1.ConnectStateString
  334.    lstConnectState.ListIndex = lstConnectState.ListCount - 1
  335. End Sub
  336.